<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="${path}/static/front/css/reset.css">
<link rel="stylesheet" type="text/css" href="${path}/static/front/css/main.css">
</head>
<body>

	<div class="form_input">
		<form id="form">
			<input type="text" name="username" class="name_input" placeholder="请输入用户名">
			<div class="user_error">输入错误</div>
			<input type="password" name="password" class="pass_input" placeholder="请输入密码">
			<div class="pwd_error">输入错误</div>
			<div class="more_input clearfix">
				<input type="checkbox" name="">
				<label>记住用户名</label>
				<a href="#">忘记密码</a>
			</div>
		</form>
		<input type="button" name="" value="登录" class="input_submit" onclick="submitForm()">
	</div>
	
	<script src="${path}/static/common/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
    <script src="${path}/static/common/layer/layer.js" type="text/javascript" charset="utf-8"></script>
    <script src="${path}/static/common/mylayer.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
	
	//1.url: ${path}/user/login.shtml
	//2.参数：表单数据
	//3.处理 结果集
		//3.1.成功：1.弹出登陆成功。 2.关闭open弹窗。3.刷新父页面。
		//3.2.失败：提到 登陆失败，检查用户名或密码。
	//4.json
	
		function submitForm() {
			$.post(
				"${path}/user/login.shtml",
				$("#form").serialize(),
				function(result) {
					console.log(result);
					if(result.success) {
						mylayer.successMsg(result.msg);
						//当你在iframe页面关闭自身时获得当前弹出框的index索引
						var index = parent.layer.getFrameIndex(window.name);
						// js一个方法，定时器，1000毫秒之后自动执行function里面的代码
						setTimeout(function() {
							 // 关闭弹出层
							 parent.layer.close(index); 
							 // 刷新父页面
							 window.parent.location.reload();
						}, 1000);
					} else {
						mylayer.errorMsg(result.msg);
					}
				},
				"json"
			);
		}
	
	</script>

</body>
</html>